package org.springblade.flow.core.utils;

import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.flow.core.constant.ProcessConstant;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LY
 * @version 1.0
 * @date 2021/1/26 10:58
 */

public class ExpenseUtil {
	private final static Map<String,String> DRAWING_PROCESS_TABLE = new HashMap<>();
	static {
		DRAWING_PROCESS_TABLE.put(ProcessConstant.EXPENSE_KEY, "data_drawing_process");
	}
	/**
	 * 通过流程key 获取业务表名
	 */
	public static String getDrawingProcessTable(String key){
		String drawingTable = DRAWING_PROCESS_TABLE.get(key);
		if (Func.isEmpty(drawingTable)) {
			throw new RuntimeException("流程启动失败,未找到相关业务表");
		}
		return drawingTable;
	}
	/**
	 * 获取业务标识
	 *
	 * @param drawingTable 业务表
	 * @param drawingId    业务表主键
	 * @return businessKey
	 */
	public static String getDrawingProcessKey(String drawingTable, String drawingId) {
		return StringUtil.format("{}:{}", drawingTable, drawingId);
	}


}
